﻿using System;
using System.Collections.Generic;
//
using PerceptiveMCAPI;
//

namespace PerceptiveMCAPI_Test
{
   public partial class get_campaignSend : System.Web.UI.UserControl
   {
      public ApiMethod method { get; set; }

      public string campaignId
      {
         get { return tbCampaignId.Text.Trim(); }
         set { tbCampaignId.Text = value; }
      }
      public DateTime sched_Time
      {
         get
         {
            DateTime dt;
            DateTime.TryParse( tbSchedTime.Text.Trim(), out dt );
            return dt;
         }
         set { tbSchedTime.Text = value.ToString(); }
      }
      public DateTime sched_Time_b
      {
         get
         {
            DateTime dt;
            DateTime.TryParse( tbSchedTime_b.Text.Trim(), out dt );
            return dt;
         }
         set { tbSchedTime_b.Text = value.ToString(); }
      }
      public List<string> emails
      {
         get { return ApiHelper.MakeListFromString( tbSendEmails.Text.Trim() ); }
      }
      public EnumValues.campaignSendTest_send_type send_type
      {
         get { return ApiHelper.GetEnumFromString<EnumValues.campaignSendTest_send_type>( ddlSendType.SelectedItem.Text ); }
         set { ddlSendType.SelectedValue = Convert.ToInt32( value ).ToString(); }
      }
      // ------------------------------------------------------------
      public void Setup()
      {
         this.Visible = true;
         lblSection.Text = method.section;
         lblMethod.Text = method.name;
         //
         divCampaignSchedule.Visible = false;
         divCampaignSendTest.Visible = false;
         tbCampaignId.Focus();
         tbSendEmails.Text = "";
         ddlSendType.DataSource = EnumValues.SendTypeValues();
         ddlSendType.DataBind();
         send_type = MCAPISettings.default_campaignSendTest_send_type;
         //
         if ( method.name == "campaignSchedule" )
            divCampaignSchedule.Visible = true;
         else if ( method.name == "campaignSendTest" )
         { divCampaignSendTest.Visible = true; }
      }
   }
}